package myky.com.doctorapp.model;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import myky.com.doctorapp.api.ApiManager;
import myky.com.doctorapp.entity.BannerEntity;
import myky.com.doctorapp.entity.CaseCountsEntity;
import myky.com.doctorapp.entity.NewCaseListEntity;
import myky.com.doctorapp.entity.RecDoctorListEntity;
import myky.com.doctorapp.entity.TagListEntity;
import myky.com.doctorapp.base.BaseEntity;
import myky.com.doctorapp.contract.HomeFragmentContract;
import myky.com.doctorapp.utils.RequestBodyBuilder;
import okhttp3.RequestBody;

public class HomeFragmentModel implements HomeFragmentContract.Model {

    @Override
    public Observable<BaseEntity<BannerEntity.PayLoadBean>> getBanner() {
        return ApiManager.getApistore().getBanner().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseEntity<TagListEntity.PayLoadBean>> getTagList(String start,String end) {
        return ApiManager.getApistore().getTagList(start,end).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseEntity<RecDoctorListEntity.DataBean>> getRecDoctorList(String version, String size, String current, String publish) {
        RequestBodyBuilder.Builder builder = new RequestBodyBuilder.Builder();
        builder.params("version", version);
        builder.params("size", size);
        builder.params("current", current);
        builder.params("publish", publish);
        RequestBody build = builder.build();
        return ApiManager.getApistore().getRecDoctorList(build).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseEntity<CaseCountsEntity.PayLoadBean>> getCaseCounts() {
        return ApiManager.getApistore().getCaseCounts().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseEntity<NewCaseListEntity.PayLoadBean>> getUserCaseList() {
        return ApiManager.getApistore().getUserCaseList().subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

}
